package com.qu.waibao;

import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;

/**
 * @描述 describe
 * @作者 Administrator
 * @创建时间 2018/7/25 16:56
 * @邮箱 1123599561@qq.com
 */
public final class AppConfig {
    public static final boolean isCanCancel = true;
    public static final boolean isEncrypt = false;
    public static final int REQUECT_CODE_ALL = 0; //全部权限
    public static final int REQUECT_CODE_LOCATION = 1; //定位
    public static final int REQUECT_CODE_SDCARD = 2; //读取sdcard
    public static final int REQUECT_CODE_CAMERA = 3; //拍照
    public static final int REQUECT_CODE_PHONE = 4; //手机状态
    public static final String APP_KEY = "25035357";  //阿里百川key
    public static final String WXAPPID = "wxabe74f4d5ba7f7e3";
    //要申请的权限
    public static final  String[] permArray ={ Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.WRITE_EXTERNAL_STORAGE,
            Manifest.permission.CAMERA,Manifest.permission.READ_PHONE_STATE,Manifest.permission.CALL_PHONE};
    public static SharedPreferences getSharedPreferences(){
        return MyApplication.getInstance().getSharedPreferences("sp",Context.MODE_PRIVATE);
    }

    public static void saveString(String key,String value){
        SharedPreferences sp = getSharedPreferences();
        SharedPreferences.Editor editor = sp.edit();
        editor.putString(key,value);
        editor.commit();
    }

    public static String getString(String key){
        return getSharedPreferences().getString(key,"");
    }

    public static void saveInt(String key,int value){
        SharedPreferences sp = getSharedPreferences();
        SharedPreferences.Editor editor = sp.edit();
        editor.putInt(key,value);
        editor.commit();
    }

    public static int getInt(String key){
        return getSharedPreferences().getInt(key,0);
    }

    public static void saveBoolean(String key,boolean value){
        SharedPreferences sp = getSharedPreferences();
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean(key,value);
        editor.commit();
    }

    public static boolean getBoolean(String key){
        return getSharedPreferences().getBoolean(key,false);
    }

    public static void saveFloat(String key,float value){
        SharedPreferences sp = getSharedPreferences();
        SharedPreferences.Editor editor = sp.edit();
        editor.putFloat(key,value);
        editor.commit();
    }

    public static float getFloat(String key){
        return getSharedPreferences().getFloat(key,0);
    }
}
